<?php
/**
 * @author fld 2021-06-21
 * @desc 操作日志控制类
 */
namespace App\Http\Controllers\Admin;

use App\Service\Admin\AdminActionlogService;
use Illuminate\Http\Request;

class AdminActionlogController extends AdminBaseController
{
    /**
     * @author fld 2021-06-18
     * @desc 登录日志列表
     * @param AdminLoginlogService $loginlogService
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(AdminActionlogService $actionlogService){
        $list = $actionlogService->getLogListByPage();
        return view('admin/actionlog/actionlog_index', $list);
    }
    /**
     * @author fld 2021-08-27
     * @desc 导出数据
     * @param AdminActionlogService $actionlogService
     * @return unknown
     */
    public function export(AdminActionlogService $actionlogService){
        return $actionlogService->export();
    }
    
    /**
     * @author fld 2021-09-08
     * @desc 导出数据
     * @param AdminActionlogService $actionlogService
     * @return unknown
     */
    public function import(Request $request,AdminActionlogService $actionlogService){
        if($request->isMethod('POST')){
            $result = $actionlogService->import($request);
            if($result['code'] == 0){
                return $this->correct($result['message'], url('admin/admin_actionlog/index'));
            }else{
                return $this->error($result['code'], $result['message'], url('admin/admin_actionlog/import'));
            }
        }else{
            return view('admin/actionlog/actionlog_import', []);
        }
    }

}
